package com.lijiankun24.shadowlayoutexample.slice;

import com.lijiankun24.shadowlayoutexample.ResourceTable;
import com.lijiankun24.shadowlayoutexample.provider.SampleItemProvider;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.ListContainer;

import java.util.ArrayList;
import java.util.List;

/**
 * 阴影列表页
 *
 * @author lijiankun
 * @since 2021-03-08
 */
public class ListAbilitySlice extends AbilitySlice {
    private static final int COUNT = 20;
    private ListContainer listContainer;
    private List<String> list;

    /**
     * onStart
     *
     * @param intent
     */
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_list);

        initComponent();
    }

    private void initComponent() {
        listContainer = (ListContainer) findComponentById(ResourceTable.Id_listContainer);
        list = new ArrayList<>();

        for (int i1 = 0; i1 < COUNT; i1++) {
            list.add("item" + i1);
        }

        SampleItemProvider provider = new SampleItemProvider(list, this);
        listContainer.setItemProvider(provider);
    }

    /**
     * onActive
     *
     */
    @Override
    public void onActive() {
        super.onActive();
    }

    /**
     * onForeground
     *
     * @param intent
     */
    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
